function OrderAbstract() {

}
OrderAbstract.prototype = {
	"APIURL": "",
	"MAXID": 0,
	"MINID": 0,
	"CURRID": 0,
	"COMMON_INPUT_DATA_ARR": ["AUDITOR", "AUDITOR_TIME", "CREATE_MAN", "CREATE_TIME", "MEMO", "ORDER_NO", "ID", "PRINTCOUNT"],
	getPageData: function() //获取表头和表尾的数据
	{
		var _data = {};
		$("#ff .easyui-combobox").each(function(index) {
			var s = $(this).attr("id");
			var subtr = deletePreSymbol("input_", s);
			_data[subtr] = $(this).combobox("getValue").trim();
		});
		$("#ff .easyui-textbox").each(function(index) {
			var s = $(this).attr("id");
			var subtr = deletePreSymbol("input_", s);
			_data[subtr] = $(this).textbox("getValue").trim();
		});
		$("#ff .easyui-datebox").each(function(index) {
			var s = $(this).attr("id");
			var subtr = deletePreSymbol("input_", s);
			_data[subtr] = $(this).datebox("getValue").trim();
		});
		$("#ff .easyui-numberbox").each(function(index) {
			var s = $(this).attr("id");
			var subtr = deletePreSymbol("input_", s);
			_data[subtr] = $(this).textbox("getValue").trim();
		});
		console.log("进入");
		this.getData(_data);
	},
	displayPageData: function() {
		var that = this;
		$("#ff .easyui-textbox").each(function(index) {
			var s = $(this).attr("id");
			var substr = deletePreSymbol("input_", s);
			if(typeof(that[substr]) != "undefined") {
				$(this).textbox("setValue", that[substr]);
			}
		});
		$("#ff .easyui-combobox").each(function(index) {
			var s = $(this).attr("id");
			var substr = deletePreSymbol("input_", s);
			if(typeof(that[substr]) != "undefined") {
				$(this).combobox("setValue", that[substr]);
			}
		});
		$("#ff .easyui-datebox").each(function(index) {
			var s = $(this).attr("id");
			var substr = deletePreSymbol("input_", s);
			if(typeof(that[substr]) != "undefined") {
				$(this).textbox("setValue", that[substr]);
			}
		});
		$("#ff .easyui-numberbox").each(function(index) {
			var s = $(this).attr("id");
			var substr = deletePreSymbol("input_", s);
			if(typeof(that[substr]) != "undefined") {
				$(this).textbox("setValue", that[substr]);
			}
		});
	},
	iniData: function() //初始化数据
	{
		var that = this;
		this.inputDataArr.forEach(function(val) {
			that[val] = "";
		});
		this.ID = -1;
	},
	getSaveData: function() {
		var outputData = new Object();
		this.getPageData();
		if(this.ID == -1) {
			this.SUBMITURL = CommonUtil.constructURL(this.APIURL, "update");
		}
		if(this.ID != -1) {
          var dataGridRows =$("#tt").edatagrid("getRows");
          this.rows=dataGridRows;
          console.log(this.rows);
		}
		outputData=this.outData();
		return outputData;
	},
	outData: function() {
		var res = new Object();
		var that = this;
		var arr;
		if(this.ID == -1) {
			arr = this.addDataArr;
		} else {
			arr = this.updateDataArr;
		}
		arr.forEach(function(val) {
			res[val] = that[val];
		});
		return res;
	},
	getData: function(data) {
		var that = this;
		this.inputDataArr.forEach(function(val) {
			if(val in data) {
				that[val] = data[val];
			}
		});

		if(this.ID != -1) {
			this.CURRID = this.ID;
		}

		if(this.rows.length != 0) {
			this.caculateSum(this.rows);
		}
	},
	getMaxAndMin: function() {
		var _url;
		var handle = new OrderHandle();
		try {
			_url = CommonUtil.constructURL(this.APIURL, "getmaxminid");
			var that = this;
			var res = handle.getRemoteData(_url);
			res.done(function(data) {
				if(data != null) {
					that.MAXID = data.MAXID;
					that.MINID = data.MINID;
					that.CURRID = data.MINID + 1;
				}
			});
		} catch(e) {
			console.log(e.message);
		}
	},
	caculateSum: function(data) {
		this.LUMP_SUM = 0;
		var _num = 0;
		if(data instanceof Array) {
			data.forEach(function(value) {
				_num += parseFloat(value.SUM);
			});
			this.LUMP_SUM = _num.toFixed(2);
			this.LUMP_SUM_CHINESE = changeMoneyToChinese(this.LUMP_SUM);
		}
	},
	getRemoteData: function(_url) {
		console.log("需要重写该函数");
	},
	prePage: function() {
		var _url = "";
		if(this.CURRID > this.MINID) {
			var param = {
				"ID": this.CURRID
			};
			_url = CommonUtil.constructURL(this.APIURL, "pre", param);
			this.getRemoteData(_url);
		} else {
			throw new Error("没有上一张");
		}
		return _url;
	},
	nextPage: function() {
		var _url = "";
		if(this.CURRID < this.MAXID) {
			var param = {
				"ID": this.CURRID
			};
			_url = CommonUtil.constructURL(this.APIURL, "next", param);
			this.getRemoteData(_url);
		} else {
			throw new Error("没有下一张");
		}
		return _url;
	},
	loadDataByID: function() {
		var _url = "";
		var param = {
			"ID": this.ID,
		}
		_url = CommonUtil.constructURL(this.APIURL, "findbyid", param);
		this.getRemoteData(_url);
	},
	deleteByID: function() {
		if(this.ISVERIFY == "1") {
			throw new Error("订单已审核,不能删除");
		}
		if(this.ID == -1) {
			throw new Error("新建订单不能删除");
		}
		if(this.ISWEB == 0) {
			throw new Error("网络订单不能删除");
		}
		var param = {
			"ID": this.ID,
		}
		$.messager.confirm('Confirm', '是否删除', function(r) {
			if(r) {
				var handle = new OrderHandle();
				_url = CommonUtil.constructURL(this.APIURL, "delete", param);
				var that = this;
				var res = handle.getRemoteData(_url);
				res.done(function(data) {
					if(data.msg.indexOf("success") != -1) {
						$.messager.alert("成功", "审核成功");
						that.nextpage();
					} else {
						$.messager.alert("失败", data.msg);
					}
				});
			}
		});

	},
	verifyByID: function() {
		var _url = "";
		if(this.ISVERIFY == "1") {
			throw new Error("订单已审核");
		}
		if(this.ID == -1) {
			throw new Error("新建订单无法审核");
		}
		var param = {
			"ID": this.ID,
		}
		var handle = new OrderHandle();
		_url = CommonUtil.constructURL(this.APIURL, "verify", param);
		var that = this;
		var res = handle.getRemoteData(_url);
		res.done(function(data) {
			if(data.msg.indexOf("success") != -1) {
				$.messager.alert("成功", "审核成功");
				that.loadDataByID();
			} else {
				$.messager.alert("成功", data.msg);
			}
		});
	},
	addCommondEventListen: function() {
		var orderEventUtil = new EventUtil();
		var that = this;
		orderEventUtil.addHandler(document, "click", function(event) {
			event = orderEventUtil.getEvent(event);
			var target = orderEventUtil.getCommandID(event);
			try {
				switch(target) {
					case "btn_save":
						that.getSaveData();
						break;
					case "btn_front":
						that.prePage();
						break;
					case "btn_next":
						that.nextPage();
						break;
					case "btn_verify":
						that.verifyByID();
						break;
					case "btn_unverify":
						that.unverifyByID();
						break;
				}
			} catch(e) {
				$.messager.alert("错误", e.message);
			}
		});
	},
	unverifyByID: function() {
		var _url = "";
		if(this.ISVERIFY == "0") {
			throw new Error("订单已弃审");
		}
		if(this.ID == -1) {
			throw new Error("新建订单无法审核");
		}
		var param = {
			"ID": this.ID,
		}
		var handle = new OrderHandle();
		_url = CommonUtil.constructURL(this.APIURL, "unverify", param);
		var that = this;
		var res = handle.getRemoteData(_url);
		res.done(function(data) {
			if(data.msg.indexOf("success") != -1) {
				$.messager.alert("成功", "弃审成功");
				that.loadDataByID();
			} else {
				$.messager.alert("成功", data.msg);
			}
		});
	},
	checkData: function() {
		console.log("需要重写该函数");
	},
	save: function() {
		console.log("需要重写该函数");
	},

}